package com.chezhujie.www.service;

import com.chezhujie.www.core.exception.ClassCheckException;
import com.chezhujie.www.core.page.Pagination;
import com.chezhujie.www.domain.Czjjqcb;
import com.chezhujie.www.persistence.CzjjqcbMapper;
import com.chezhujie.www.utils.UUIDUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.ui.ModelMap;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;


/**
 * 集群车宝商品
 * Created by 汤伟杰 on 2017/5/23.
 */
@Service
public class CzjjqcbService extends BaseService<Czjjqcb>{
    @Autowired
    private CzjjqcbMapper czjjqcbMapper;

    @Autowired
    public void setBaseMapper(CzjjqcbMapper czjjqcbMapper) {
        this.baseMapper = czjjqcbMapper;
    }


    public void checkEntity(Czjjqcb czjjqcb) throws ClassCheckException {
        if(czjjqcb.getJqcbId()!=null&&czjjqcb.getJqcbId().length()>19){
            throw new ClassCheckException("集群车宝商品主键不能超过19个字符");
        }
        if(czjjqcb.getPicPath()!=null&&czjjqcb.getPicPath().length()>255){
            throw new ClassCheckException("集群车宝商品图片不能超过255个字符");
        }
        if(czjjqcb.getTitle()!=null&&czjjqcb.getTitle().length()>10){
            throw new ClassCheckException("集群车宝商品标题不能超过10个字符");
        }
        if(czjjqcb.getContent()!=null&&czjjqcb.getContent().length()>100){
            throw new ClassCheckException("集群车宝商品内容不能超过100个字符");
        }
        if(czjjqcb.getUrl()!=null&&czjjqcb.getUrl().length()>1000){
            throw new ClassCheckException("集群车宝商品外链接不能超过1000个字符");
        }
    }
    public void checkListEntity(List<Czjjqcb> listCzjjqcb) throws ClassCheckException {

        for (Czjjqcb czjjqcb : listCzjjqcb) {
            checkEntity(czjjqcb);
        }

    }
}
